package cwb1;

/**
 * 
 * @author Aurora
 *
 */
public class GraphEngine {
	//Design pattern singleton.
	private static GraphEngine instance = new GraphEngine();
	
	/**
	 * There is no possibility of creating an object of this class.
	 */
	private GraphEngine()
	{
	}
	
	/**
	 * This method returns the only possible operational instance of the GraphEngine class.
	 * 
	 * @return The only possible operational instance of the GraphEngine class.
	 */
	public static GraphEngine getInstance()
	    {
	        return instance;
	    }
	
	/**
	 * retourneert het gemiddelde van een bepaald type activiteit
	 * [0]: duur activiteit.
	 * [1]: duur pauze.
	 * @param activity
	 * @return
	 */
	public long[] getActivityVSPause(User user, long type) {
		long[] data = {0,0};
		for(Activity lusActivity : ActivityRegistry.getInstance().getAllActivityUserType(user, type)) {
			data[0] = data[0] + lusActivity.getDuration();
			data[1] = data[1] + lusActivity.getPauseDuration();
		}
		return data;
	}
	
	/**
	 * 
	 */
	public long[] getAllActivityDuration(User user) {
		long[] data = {0,0,0,0,0,0,0};
		for(Activity element : ActivityRegistry.getInstance().getAllActivitiesUser(user.getId()))
		{
			int temp = (int) element.getType();
			data[temp-1]=data[temp-1] + element.getDuration();
		}
		return data;
	}
	

	
}


